<!-- <script>
//选项式API
export default {
  data() {
    return {
      count: 0
    }
  },
  methods: {
    addCount() {
      this.count++
    }
  }
}
</script> -->

<script>
//使用组合式API必须加一个入口setup(最早执行的函数)
import { ref } from 'vue'
export default {
  setup() {
    const count = ref(0)
    const addCount = () => {
      count.value++
    }
    return {
      count,
      addCount
    }
  }
}
</script>

<template>
  <div class="box">
    <button @click="addCount">+{{ count }}</button>
  </div>
</template>

<style scoped>

</style>
